import type { ContextMenuItem } from '@/components/ContextMenu';

import { getCurrentInstance, onUnmounted } from 'vue';

import { createContextMenu, destroyContextMenu } from '@/components/ContextMenu';

export type { ContextMenuItem };

/** 使用上下文菜单 */
export function useContextMenu(authRemove = true) {
  if (getCurrentInstance() && authRemove) {
    onUnmounted(() => {
      destroyContextMenu();
    });
  }
  return {
    /** 创建上下文菜单 */
    createContextMenu,
    /** 销毁上下文菜单 */
    destroyContextMenu,
  };
}
